package engine.video.blit;

import common.Coordinate;
import common.Rectangle;
import engine.video.palette.PaletteMap;

/**
 * SpriteInfo Stores information used by the Blitter class to perform pixel copy
 * operations.
 **/
public class SpriteInfo {
	public SpriteInfo(PixelBuffer_I image, PixelBuffer_I mask, 
			Coordinate offset, Rectangle clipRect) {
		Image = image;
		Mask = mask;
		Offset = offset;
		if(clipRect == null) {
			ClipRect = new Rectangle(0, 0, image.getWidth(), image.getHeight());
		} else {
			ClipRect = clipRect;
		}
	}
	
	public SpriteInfo(PixelBuffer_I pixelBuffer) {
		Offset = new Coordinate(0, 0);
		ClipRect = new Rectangle(0, 0, pixelBuffer.getWidth(), pixelBuffer.getHeight());
		Image = pixelBuffer;
		Mask = null;
	}
	
	public SpriteInfo(Rectangle clipRect, PixelBuffer_I pixelBuffer) {
		Offset = new Coordinate(0, 0);
		Image = pixelBuffer;
		Mask = null;
		if(clipRect == null) {
			ClipRect = new Rectangle(0, 0, pixelBuffer.getWidth(), pixelBuffer.getHeight());
		} else {
			ClipRect = clipRect;
		}
	}
	
	public SpriteInfo(int ofsX, int ofsY, Rectangle clipRect, PixelBuffer_I pixelBuffer) {
		Offset = new Coordinate(ofsX, ofsY);
		Image = pixelBuffer;
		Mask = null;
		if(clipRect == null) {
			ClipRect = new Rectangle(0, 0, pixelBuffer.getWidth(), pixelBuffer.getHeight());
		} else {
			ClipRect = clipRect;
		}
	}


	public boolean isValid() {
		if (Image == null) {
			return false;
		} else {
			return true;
		}
	}
	
	public final PixelBuffer_I Image;
	public final PixelBuffer_I Mask;
	// Rendering offset.
	public final Coordinate Offset;
	// Source Clipping rectangle, relative to Pixels(0,0)
	public final Rectangle ClipRect;
}